<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>判断一个人的年龄是否满18岁(是否成年)</title>
</head>

<body>
    <script>
        var age = 22;
//第一种
        if(age > 0 && !isNaN(Number(age))){
            if(age < 18){
                console.log('未成年');
            }else {
                console.log('已成年')
            }
        }


//第二种
        if (age > 0) {
            var adult = '已成年';
            if (age < 18) {
                adult = '未成年';
            }
            console.log(adult);
        }
    </script>
</body>

</html>